﻿using LY.DataAccess.Repository;
using LY.Entity;
using LY.Entity.PageSearch;
using LY.Entity.SearchEntity;
using LY.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LY.Business.ServiceImpl
{
    class LinksService : IlinksService
    {
        LinksRepository _links;
        public LinksService()
        {
            _links = new LinksRepository();
        }
        //列表展示
        public PagedList<C_Links> QueryLinksList(LinksSearch search, PageView view)
        {
            return _links.LinksList(search, view);
        }

        /// <summary>
        /// 新增或修改时保存信息
        /// </summary>
        /// <param name="links"></param>
        /// <returns></returns>
        public int SaveLinks(C_Links links)
        {
            if (links.Id <= 0)
            {
                //执行新增操作
                return (int)_links.Insert(links);
            }
            else
            {
                //执行修改操作
                return (int)_links.Update(links);
            }
        }

        //根据id检索链接信息
        public C_Links GetLinks(int? id)
        {
            return _links.GetLinks(id);
        }

        //删除
        public int DeleteLinks(int id)
        {
            return _links.DeleteLinks(id);
        }
    }
}
